//
//  KLBaseTableViewController.swift
//  BCWeiBo
//
//  Created by bcmac3 on 16/3/31.
//  Copyright © 2016年 KellenYangs. All rights reserved.
//

import UIKit

class KLBaseTableViewController: UITableViewController, KLVisitorViewDelegate {

    // 定义变量保存用户是否登录
    var login:Bool = KLUserAccount.userLogin()
    var visitorView: KLVisitorView?
    
    override func loadView() {
        login ? super.loadView() : setupVisitor()
    }
    
    /**
     创建访客视图
     */
    private func setupVisitor()
    {
        
        // 1.创建访客视图
        visitorView = KLVisitorView()
        visitorView?.delegate = self
        view = visitorView
        
        // 2. 设置状态栏
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewLogin")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewRegister")
        
    }
    
    // MARK: - VisitorViewDelegate
    func visitorViewLogin() {
        print(__FUNCTION__)
        let oauthVC = KLOAuthViewController()
        let nav = UINavigationController(rootViewController: oauthVC)
        presentViewController(nav, animated: true, completion: nil)
    }
    
    func visitorViewRegister() {
        print(__FUNCTION__)
    }

}













